home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / libqdisplay / surface8.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-10  |  1.6 KB  |  70 lines

  1. static void BuildSky8(unsigned char *out, unsigned char *in)
  2. {
  3.   __memcpy(out, in, SKY_X * SKY_Y * sizeof(unsigned char));
  4. }
  5.  
  6. static void BuildLightBlock8(unsigned char *out, struct bitmap *raw, int x, int y)
  7. {
  8.   int c, dc;
  9.   int a, b, h, c0, c1, c2, c3;
  10.   int y_max = raw->height, x_max = raw->width;
  11.   unsigned char *fullbright = raw->data + lookup(y, raw->width);
  12.  
  13.   c0 = ((255 << 6) - lightmapIndex[0]);
  14.   c1 = ((255 << 6) - lightmapIndex[1]);
  15.   c2 = ((255 << 6) - lightmapIndex[lightmapWidth]);
  16.   c3 = ((255 << 6) - lightmapIndex[lightmapWidth + 1]);
  17.  
  18.   c2 = (c2 - c0) >> shift;
  19.   c3 = (c3 - c1) >> shift;
  20.  
  21.   for (b = 0; b < step; ++b) {
  22.     h = x;
  23.     c = c0;
  24.     dc = (c1 - c0) >> shift;
  25.     for (a = 0; a < step; ++a) {
  26.       unsigned char pel = fullbright[h];
  27.  
  28.       *out++ = cachedColormap[(c & 0x00003F00) + (int)pel];
  29.       c += dc;
  30.       if (++h == x_max)
  31.     h = 0;
  32.     }
  33.     out += row;
  34.     c0 += c2;
  35.     c1 += c3;
  36.     if (++y == y_max) {
  37.       y = 0;
  38.       fullbright = raw->data;
  39.     }
  40.     else
  41.       fullbright += raw->width;
  42.   }
  43. }
  44.  
  45. static unsigned char *brightColormap;
  46. static void BuildBrightBlock8(unsigned char *out, struct bitmap *raw, int x, int y)
  47. {
  48.   int a, b, h;
  49.   int y_max = raw->height, x_max = raw->width;
  50.   unsigned char *fullbright = raw->data + lookup(y, raw->width);
  51.  
  52.   for (b = 0; b < step; ++b) {
  53.     h = x;
  54.     for (a = 0; a < step; ++a) {
  55.       unsigned char pel = fullbright[h];
  56.  
  57.       *out++ = brightColormap[(int)pel];
  58.       if (++h == x_max)
  59.     h = 0;
  60.     }
  61.     out += row;
  62.     if (++y == y_max) {
  63.       y = 0;
  64.       fullbright = raw->data;
  65.     }
  66.     else
  67.       fullbright += raw->width;
  68.   }
  69. }
  70.